//
//  main.m
//  oc_27
//
//  Created by 楼楚 on 15/9/17.
//  Copyright (c) 2015年 Chu Lou. All rights reserved.
//

#import <Foundation/Foundation.h>
#define PATH @"/Users/louchu/code/oc_exercise"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       
        NSFileManager *fm = [NSFileManager defaultManager];//创建文件管理单例类
        
        NSError *error;
       NSArray *files  = [fm contentsOfDirectoryAtPath:PATH error:&error];
//        NSLog(@"%@",files);
        
        NSArray *subFiles = [fm subpathsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/oc_17",PATH] error:&error];
//        NSLog(@"%@",subFiles);
//        BOOL ret = [fm createDirectoryAtPath:[NSString stringWithFormat:@"%@/test",PATH] withIntermediateDirectories:NO attributes:nil error:&error];
//        if (ret) {
//            NSLog(@"file created");
//        }else
//        {
//            NSLog(@"%@",[error description]);
//        }
        
        BOOL ret1= [fm createFileAtPath:[NSString stringWithFormat:@"%@/test/test",PATH] contents:[@"test"dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
        if (ret1) {
            NSLog(@"file created");
        }else
        {
            NSLog(@"%@",[error description]);
        }
        BOOL ret2 = [fm removeItemAtPath:[NSString stringWithFormat: @"%@/test/test",PATH] error:&error];
        if (ret2) {
            NSLog(@"file deleted");
        }else
        {
            NSLog(@"%@",[error description]);
        }
        
    }
    return 0;
}
